//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package net.mingsoft.base.util;

import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.i18n.LocaleContextHolder;

public class BundleUtil {
    protected static final Logger LOG = LoggerFactory.getLogger(BundleUtil.class);

    public BundleUtil() {
    }

    /** @deprecated */
    @Deprecated
    public static String getLocaleString(String key, String resources) {
        Locale locale = LocaleContextHolder.getLocale();
        return ResourceBundle.getBundle(resources, locale).getString(key);
    }

    /** @deprecated */
    @Deprecated
    public static String getResString(String key) {
        return getLocaleString(key, "net.mingsoft.base.resources.resources");
    }

    /** @deprecated */
    @Deprecated
    public static String getResString(String key, ResourceBundle rb) {
        try {
            return rb.getString(key);
        } catch (MissingResourceException var3) {
            return getLocaleString(key, "net.mingsoft.base.resources.resources");
        }
    }

    /** @deprecated */
    @Deprecated
    public static String getResString(String key, String... fullStrs) {
        String temp = getResString(key);

        for(int i = 0; i < fullStrs.length; ++i) {
            temp = temp.replace("{" + i + "}", fullStrs[i]);
        }

        return temp;
    }

    /** @deprecated */
    @Deprecated
    public static String getResString(String key, ResourceBundle rb, String... fullStrs) {
        String temp = "";

        try {
            temp = rb.getString(key);
        } catch (MissingResourceException var5) {
            temp = getResString(key);
        }

        for(int i = 0; i < fullStrs.length; ++i) {
            temp = temp.replace("{" + i + "}", fullStrs[i]);
        }

        return temp;
    }

    /** @deprecated */
    @Deprecated
    public static String getLocalString(String key, String... fullStrs) {
        String temp = getResString(key);

        for(int i = 0; i < fullStrs.length; ++i) {
            temp = temp.replace("{" + i + "}", fullStrs[i]);
        }

        return temp;
    }

    public static String getString(String resources, String key, String... params) {
        Locale locale = LocaleContextHolder.getLocale();
        String temp = "";

        try {
            temp = ResourceBundle.getBundle(resources, locale).getString(key);
        } catch (MissingResourceException var6) {
            LOG.debug("不存在资源文件:{}", resources);
            var6.printStackTrace();
        }

        for(int i = 0; i < params.length; ++i) {
            temp = temp.replace("{" + i + "}", params[i]);
        }

        return temp;
    }

    public static String getBaseString(String key, String... params) {
        Locale locale = LocaleContextHolder.getLocale();
        String temp = "";
        temp = ResourceBundle.getBundle("net.mingsoft.base.resources.resources", locale).getString(key);

        for(int i = 0; i < params.length; ++i) {
            temp = temp.replace("{" + i + "}", params[i]);
        }

        return temp;
    }
}
